<!-- mate start -->
<?php $this->load->view('assists/mate.php') ?>
<!-- mate end -->
<link rel="stylesheet" href="<?=base_url('static/index/css/menu.css')?>">
<link rel="stylesheet" href="<?=base_url('static/index/css/user_center.css')?>" />
<title>用户中心</title>
<!-- header strat -->
<?php $this->load->view('assists/header.php') ?>
<!-- header end -->
	<div id="top-alert" class="fixed alert-success" style="display:none;">
    	<button class="close fixed" >×</button>
    	<p class="alert-content">这是内容</p>
    </div>
	<div id="user_center">
		<div class="user_center clearfix">
			<?php $this->load->view('assists/menu.php') ?>
			<div class="user_info">
				<div class="AdminHead">
					<h2>个人资料</h2>
				</div>
				<div class="person_data">
					<form action="<?=site_url('User_center/change_data')?>" method="post" class="change_form">
						<ul class="person_data_ul">
							<li class="user_logo clearfix">
								<div class="user_logo_left">头像</div>
								<div class="user_logo_right"><img src="<?=base_url($user_message['logo'])?>" /></div>
							</li>
							<li class="person_data_li clearfix">
								<div class="person_data_left">用户名</div>
								<div class="person_data_right"><?=$user_message['username']?></div>
							</li>
							<li class="person_data_li clearfix">
								<div class="person_data_left">邮箱</div>
								<div class="person_data_right"><?=$user_message['email']?></div>
							</li>
							<li class="person_data_li clearfix">
								<div class="person_data_left">电话</div>
								<div class="person_data_right"><input type="text" value="<?=$user_message['telephone']?>" name="telephone" id="telephone" class="telephone" /></div>
							</li>
						</ul>
						<div class="change_data">
							<input type="button" value="保存修改" class="change_data_btn" />
						</div>
						<div class="show_error_message"></div>
					</form>
				</div>
			</div>
		</div>
	</div>
	
	<!-- footer start -->
   	<?php $this->load->view('assists/footer.php') ?>
   	<!-- footer end -->
   	<script type="text/javascript" src="<?=base_url('static/index/js/changepwd.js')?>"></script>
   	<script type="text/javascript">
   		$(".change_data_btn").click(function(){
   			var url = $(".change_form").get(0).action;
   			var telephone = $("#telephone").val();
   			var reg = /^(0|86|17951)?(13[0-9]|15[012356789]|18[0-9]|14[57])[0-9]{8}$/;
   			var flag;
   			flag = reg.test(telephone);
   			if(!flag){
   	   			$(".show_error_message").html("电话格式有误,请重新输入!!");
   	   			return false;
   	   		}
   	   		$.post(url,{telephone:telephone},function(data){
	   	   		if(data.flag == 0){
	    			alert(data.content);
	    		}else if(data.flag == 1){
	    			updateAlert(data.content,true);
	    			setTimeout(function(){
						if(data.url)
						{
							location.href=data.url;
						}
						else{
							location.reload();
						}
					},1500);
	    		}else if(data.flag ==-1){
	    			updateAlert(data.content);
	    		}
   	   	   	},"json");

   	   	   	
   	   //警告栏显示
   	 	var am_alert = $('#top-alert');
   	 	var alert_button = am_alert.find('button');
   	 	alert_button.click(function(){
   	 		am_alert.hide();
   	 	});
   	 	window.updateAlert = function(text,c)
   	 	{
   	 		text = text||'default';
   	 		c = c||false;
   	 		am_alert.css("display","block");
   	 		if(text!='default'){
   	 			am_alert.find('p').text(text);
   	 		}
   	 		else{
   	 			am_alert.find('p').text('这是内容!');
   	 		}
   	 		if(c==false)
   	 		{
   	 			am_alert.removeClass("alert-success").addClass(' alert-error');
   	 		}else{
   	 			am_alert.removeClass("alert-error").addClass(" alert-success");
   	 		}
   	 	}
   	   	});
   	</script>
</body>
</html>